﻿Public Class Drucken_Klasse
    Dim data
    Public überschrift = "noname"
    Public abstand = 50
    Dim cu_px = 300

    Public Function drucken()
        Dim pdia As New PrintDialog

        cu_px = 300


        Dim pd As New Printing.PrintDocument
        pd.DocumentName = überschrift
        AddHandler pd.PrintPage, AddressOf PrintPage
        If pdia.ShowDialog = Windows.Forms.DialogResult.OK Then
            pd.PrinterSettings = pdia.PrinterSettings
            pd.Print()
        End If
        Return "OK"
    End Function

    Public Function add(ByVal Feld1 As String, ByVal Feld2 As String)
        If data = "" Then
        Else
            data = data + ","
        End If
        data = data + Feld1 & "/" & Feld2
        Return "OK"
    End Function

    Public Function clear()
        data = ""
        Return "OK"
    End Function


    Sub PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)




        e.Graphics.DrawString(überschrift, New Font("Arial", 55, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, New Point(280, 60))
        e.Graphics.DrawLine(Pens.Black, New Point(0, 160), New Point(830, 160))
        e.Graphics.DrawLine(Pens.Black, New Point(0, 161), New Point(830, 161))
        e.Graphics.DrawLine(Pens.Black, New Point(0, 162), New Point(830, 162))
        e.Graphics.DrawLine(Pens.Black, New Point(0, 163), New Point(830, 163))




        For Each s As String In data.Split(",")


            Dim dataArr() As String = s.Split("/")
            With e.Graphics
                .DrawString(dataArr(0), New Font("Arial", 25, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, New Point(150, cu_px))
                .DrawString(dataArr(1), New Font("Arial", 25, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.Black, New Point(475, cu_px))
            End With

            cu_px = cu_px + abstand
        Next





    End Sub


End Class
